From c602de446c7a0c09fa0fba453122c7af788abb6c Mon Sep 17 00:00:00 2001 From: oliskoli Date: Sat, 26 Apr 2008 10:49:36 +0000 Subject: [PATCH] Add new format 'VidaOne'. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@3214 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/Makefile.in | 4 +- gpsbabel/testo | 4 ++ gpsbabel/vecs.c | 7 +++ gpsbabel/vidaone.c | 134 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 gpsbabel/vidaone.c diff --git a/gpsbabel/Makefile.in b/gpsbabel/Makefile.in index 03c5a2811..7da093f41 100644 --- a/gpsbabel/Makefile.in +++ b/gpsbabel/Makefile.in @@ -58,7 +58,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \ yahoo.o unicsv.o wfff_xml.o garmin_txt.o axim_gpb.o gpssim.o \ wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \ ggv_log.o g7towin.o garmin_gpi.o lmx.o random.o xol.o dg-100.o \ - navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o + navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o vidaone.o FMTS=@FMTS@ @@ -724,6 +724,8 @@ vcf.o: vcf.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h vecs.o: vecs.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h csv_util.h +vidaone.o: vidaone.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h vitosmt.o: vitosmt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h vitovtt.o: vitovtt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ diff --git a/gpsbabel/testo b/gpsbabel/testo index 45e8c4016..b6a9a4ed7 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -1327,5 +1327,9 @@ compare ${TMPDIR}/destinator_trl.txt ${REFERENCE}/track/destinator_trl.txt ${PNAME} -i exif -f ${REFERENCE}/IMG_2065.JPG -o unicsv,utc=0 -F ${TMPDIR}/exif-dat.csv compare ${TMPDIR}/exif-dat.csv ${REFERENCE}/exif-dat.csv +# VidaOne track logs +${PNAME} -i vidaone -f ${REFERENCE}/track/vidaone.gpb -t -o unicsv -F ${TMPDIR}/vidaone.csv +compare ${TMPDIR}/vidaone.csv ${REFERENCE}/track/vidaone.csv + exit 0 diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 370d0e60b..bca12ebeb 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -136,6 +136,7 @@ extern ff_vecs_t destinator_poi_vecs; extern ff_vecs_t destinator_trl_vecs; extern ff_vecs_t destinator_itn_vecs; extern ff_vecs_t exif_vecs; +extern ff_vecs_t vidaone_vecs; static vecs_t vec_list[] = { @@ -767,6 +768,12 @@ vecs_t vec_list[] = { "Embedded Exif-GPS data (.jpg)", "jpg" }, + { + &vidaone_vecs, + "vidaone", + "VidaOne track logs (.gpb)", + "gpb" + }, #endif // MAXIMAL_ENABLED { NULL, diff --git a/gpsbabel/vidaone.c b/gpsbabel/vidaone.c new file mode 100644 index 000000000..40904d7e6 --- /dev/null +++ b/gpsbabel/vidaone.c @@ -0,0 +1,134 @@ +/* + + Support for "VidaOne Diet & Fittness" data files (.gpb) + + Copyright (C) 2008 Olaf Klein, o.b.klein@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + + /* + Simple layout: + + struct + { + double dLatitude + double dLongitude + float fReserved + }; + */ + +#include "defs.h" +#include +#include + +#define MYNAME "vidaone" + +static +arglist_t vidaone_args[] = { + ARG_TERMINATOR +}; + +static gbfile *fin, *fout; + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ + +static void +vidaone_rd_init(const char *fname) +{ + fin = gbfopen(fname, "rb", MYNAME); +} + +static void +vidaone_rd_deinit(void) +{ + gbfclose(fin); +} + +static void +vidaone_read(void) +{ + route_head *trk = NULL; + + while (! gbfeof(fin)) { + waypoint *wpt = waypt_new(); + + wpt->latitude = gbfgetdbl(fin); + wpt->longitude = gbfgetdbl(fin); + (void) gbfgetflt(fin); + + /* Only one basic check of data integrity */ + if ((fabs(wpt->latitude) > 90) || (fabs(wpt->longitude) > 180)) + fatal(MYNAME ": Latitude and/or longitude out of range.\n"); + + if (!trk) { + trk = route_head_alloc(); + track_add_head(trk); + } + + track_add_wpt(trk, wpt); + } +} + +static void +vidaone_wr_init(const char *fname) +{ + fout = gbfopen(fname, "wb", MYNAME); +} + +static void +vidaone_wr_deinit(void) +{ + gbfclose(fout); +} + +static void +vidaone_trkpt(const waypoint *wpt) +{ + gbfputdbl(wpt->latitude, fout); + gbfputdbl(wpt->longitude, fout); + gbfputflt(0, fout); +} + +static void +vidaone_write(void) +{ + track_disp_all(NULL, NULL, vidaone_trkpt); +} + +/**************************************************************************/ + +ff_vecs_t vidaone_vecs = { + ff_type_file, + { + ff_cap_none /* waypoints */, + ff_cap_read | ff_cap_write /* tracks */, + ff_cap_none /* routes */ + }, + vidaone_rd_init, + vidaone_wr_init, + vidaone_rd_deinit, + vidaone_wr_deinit, + vidaone_read, + vidaone_write, + NULL, + vidaone_args, + CET_CHARSET_UTF8, 1 +}; + +/**************************************************************************/ -- 2.30.2